import GameView from "../../../../quick/core/ui/GameView";
import UIQRCode from "../../../../quick/core/ui/UIQRCode";
import { inject } from "../../../../quick/defines/Decorators";

const {ccclass, property} = cc._decorator;

@ccclass
export default class QRCodeView extends GameView {

    public static getPrefabUrl(): string {
        return "prefabs/QRCodeView";
    }

    @inject("goback",cc.Node)
    private goback : cc.Node = null!;

    @inject("editbox",cc.EditBox)
    private editbox : cc.EditBox = null!;

    @inject("qrcode",UIQRCode)
    private qrcode : UIQRCode = null!;

    onLoad(): void {
        super.onLoad();
        this.onN(this.goback,cc.Node.EventType.TOUCH_END,this.backBundle);
        let eventHandler = new cc.Component.EventHandler;
        eventHandler.component = "QRCodeView";
        eventHandler.target = this.node;
        eventHandler.handler = "onTextChanged"
        this.editbox.textChanged.push(eventHandler);
    }

    private onTextChanged(data:string){
        this.qrcode.string = data;
    }
}
